/*
 * @(#)MaintCalendarPerferenceForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.calendar.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.calendar.bean.CalendarPerference;
import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;

/**
  MaintCalendarPerferenceForm.java

  This class is the for web form purpose.

  @author      Tony Chen
  @company     DCIVision Limited
  @creation date   05/12/2003
  @version     $Revision: 1.5 $
*/

public class MaintCalendarPerferenceForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.5 $";

  private String userRecordID = null;
  private String defaultView = null;
  private String displayTimeInterval = null;
  private String weekBeginOn = null;
  private String startShowHour = null;
  private String endShowHour = null;
  private String defaultGroup = null;
  

  public MaintCalendarPerferenceForm() {
    super();
  }

  public String getUserRecordID() {
    return(this.userRecordID);
  }

  public void setUserRecordID(String userRecordID) {
    this.userRecordID = userRecordID;
  }

  public String getDefaultView() {
    return(this.defaultView);
  }

  public void setDefaultView(String defaultView) {
    this.defaultView = defaultView;
  }

  public String getDisplayTimeInterval() {
    return(this.displayTimeInterval);
  }

  public void setDisplayTimeInterval(String displayTimeInterval) {
    this.displayTimeInterval = displayTimeInterval;
  }

  public String getWeekBeginOn() {
    return(this.weekBeginOn);
  }

  public void setWeekBeginOn(String weekBeginOn) {
    this.weekBeginOn = weekBeginOn;
  }

  public String getStartShowHour() {
    return(this.startShowHour);
  }

  public void setStartShowHour(String startShowHour) {
    this.startShowHour = startShowHour;
  }

  public String getEndShowHour() {
    return(this.endShowHour);
  }

  public void setEndShowHour(String endShowHour) {
    this.endShowHour = endShowHour;
  }
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setUserRecordID(null);
    this.setDefaultView(null);
    this.setDisplayTimeInterval(null);
    this.setWeekBeginOn(null);
    this.setStartShowHour(null);
    this.setEndShowHour(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    CalendarPerference tmpCalendarPerference = new CalendarPerference();
    tmpCalendarPerference.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpCalendarPerference.setUserRecordID(TextUtility.parseIntegerObj(this.getUserRecordID()));
    tmpCalendarPerference.setDefaultView(this.getDefaultView());
    tmpCalendarPerference.setDisplayTimeInterval(TextUtility.parseFloatObj(this.getDisplayTimeInterval()));
    tmpCalendarPerference.setWeekBeginOn(this.getWeekBeginOn());
    tmpCalendarPerference.setStartShowHour(TextUtility.parseIntegerObj(this.getStartShowHour()));
    tmpCalendarPerference.setEndShowHour(TextUtility.parseIntegerObj(this.getEndShowHour()));
    tmpCalendarPerference.setDefaultGroup(TextUtility.parseIntegerObj(this.getDefaultGroup()));
    tmpCalendarPerference.setRecordStatus(this.getRecordStatus());
    tmpCalendarPerference.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpCalendarPerference.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpCalendarPerference.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpCalendarPerference.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpCalendarPerference.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpCalendarPerference;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    CalendarPerference tmpCalendarPerference = (CalendarPerference)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpCalendarPerference.getID()));
    this.setUserRecordID(TextUtility.formatIntegerObj(tmpCalendarPerference.getUserRecordID()));
    this.setDefaultView(tmpCalendarPerference.getDefaultView());
    this.setDisplayTimeInterval(TextUtility.formatFloat(
        (tmpCalendarPerference.getDisplayTimeInterval()==null? 0:tmpCalendarPerference.getDisplayTimeInterval().intValue())));
    this.setWeekBeginOn(tmpCalendarPerference.getWeekBeginOn());
    this.setStartShowHour(TextUtility.formatIntegerObj(tmpCalendarPerference.getStartShowHour()));
    this.setEndShowHour(TextUtility.formatIntegerObj(tmpCalendarPerference.getEndShowHour()));
    this.setDefaultGroup(TextUtility.formatIntegerObj(tmpCalendarPerference.getDefaultGroup()));
    this.setRecordStatus(tmpCalendarPerference.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpCalendarPerference.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpCalendarPerference.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpCalendarPerference.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpCalendarPerference.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpCalendarPerference.getUpdateDate()));
  }
  public String getDefaultGroup() {
    return defaultGroup;
  }
  public void setDefaultGroup(String defaultGroup) {
    this.defaultGroup = defaultGroup;
  }
}
